package com.ruoyi.ylyx.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.IdWorker;
import com.ruoyi.ylyx.domain.YlyxRecruitpost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ylyx.mapper.YlyxRecuittypeMapper;
import com.ruoyi.ylyx.domain.YlyxRecuittype;
import com.ruoyi.ylyx.service.IYlyxRecuittypeService;
import com.ruoyi.common.core.text.Convert;

/**
 * 招聘类别Service业务层处理
 * 
 * @author yuexl
 * @date 2021-02-05
 */
@Service
public class YlyxRecuittypeServiceImpl implements IYlyxRecuittypeService 
{
    @Autowired
    private YlyxRecuittypeMapper ylyxRecuittypeMapper;

    /**
     * 查询招聘类别
     * 
     * @param id 招聘类别ID
     * @return 招聘类别
     */
    @Override
    public YlyxRecuittype selectYlyxRecuittypeById(String id)
    {
        return ylyxRecuittypeMapper.selectYlyxRecuittypeById(id);
    }

    /**
     * 查询招聘类别列表
     * 
     * @param ylyxRecuittype 招聘类别
     * @return 招聘类别
     */
    @Override
    public List<YlyxRecuittype> selectYlyxRecuittypeList(YlyxRecuittype ylyxRecuittype)
    {
        return ylyxRecuittypeMapper.selectYlyxRecuittypeList(ylyxRecuittype);
    }

    /**
     * 新增招聘类别
     * 
     * @param ylyxRecuittype 招聘类别
     * @return 结果
     */
    @Override
    public int insertYlyxRecuittype(YlyxRecuittype ylyxRecuittype)
    {
        ylyxRecuittype.setId(IdWorker.getId());
        ylyxRecuittype.setCreateTime(DateUtils.getNowDate());
        return ylyxRecuittypeMapper.insertYlyxRecuittype(ylyxRecuittype);
    }

    /**
     * 修改招聘类别
     * 
     * @param ylyxRecuittype 招聘类别
     * @return 结果
     */
    @Override
    public int updateYlyxRecuittype(YlyxRecuittype ylyxRecuittype)
    {
        ylyxRecuittype.setUpdateTime(DateUtils.getNowDate());
        return ylyxRecuittypeMapper.updateYlyxRecuittype(ylyxRecuittype);
    }

    /**
     * 删除招聘类别对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteYlyxRecuittypeByIds(String ids)
    {
        return ylyxRecuittypeMapper.deleteYlyxRecuittypeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除招聘类别信息
     * 
     * @param id 招聘类别ID
     * @return 结果
     */
    @Override
    public int deleteYlyxRecuittypeById(String id)
    {
        return ylyxRecuittypeMapper.deleteYlyxRecuittypeById(id);
    }

    @Override
    public List<YlyxRecuittype> selectTypeByRecruitId(String recruitId) {
        YlyxRecruitpost ylyxRecruitpost = ylyxRecuittypeMapper.selectTypeByRecruitId(recruitId);
        List<YlyxRecuittype> ylyxRecuittypeList = ylyxRecuittypeMapper.selectYlyxRecuittypeList(new YlyxRecuittype());
        for (int i=0;i<ylyxRecuittypeList.size();i++)
        {
            if (ylyxRecruitpost.getRecruitType().equals(ylyxRecuittypeList.get(i).getId()))
            {
                ylyxRecuittypeList.get(i).setFlag(true);
                break;
            }
        }
        return ylyxRecuittypeList;
    }
}
